package com.vm.adapter;

import java.util.List;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.vm.activity.BitmapCache;
import com.vm.adapter.LatestAppAdapter.ViewHolder;
import com.vm.commons.StringUtil;
import com.vm.commons.VMConst;
import com.vm.model.Soft;
import com.vm.utils.MyDisplayImageOptions;
import com.wwt.app.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

public class IntergralAdapter extends BaseAdapter {
	private Context mContext;
	private List<Soft> listSofts;

	/**
	 * 
	 */
	public IntergralAdapter(Context context, List<Soft> lists) {
		this.mContext = context;
		this.listSofts = lists;
	}

	@Override
	public int getCount() {
		return listSofts.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder = null;
		if (convertView == null) {

			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.have_getted_item, null);
			viewHolder = new ViewHolder();

			/**
			 * 获取各个需要显示属性的控件
			 */
			viewHolder.tv_softName = (TextView) convertView
					.findViewById(R.id.tv_softName);
			viewHolder.iv_softImage = (ImageView) convertView
					.findViewById(R.id.iv_softImage);
			viewHolder.tv_geted_integral_num = (TextView) convertView
					.findViewById(R.id.tv_geted_integral_num);

			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}

		Soft soft = listSofts.get(position);

		viewHolder.tv_softName.setTag(soft.getId());
		// 名称

		if (soft.getName() != null) {
			String softName = StringUtil.getShotName(soft.getName());
			viewHolder.tv_softName.setText(softName);
		}

		viewHolder.tv_geted_integral_num.setText(Integer.toString(soft
				.getSupport()));

		// ImageListener listener = ImageLoader.getImageListener(
		// viewHolder.iv_softImage, android.R.drawable.ic_menu_rotate,
		// android.R.drawable.ic_delete);

		ImageLoader.getInstance().displayImage(
				VMConst.URL + soft.getImageUrl(), viewHolder.iv_softImage,
				MyDisplayImageOptions.getInstance());
		return convertView;

	}

	static class ViewHolder {
		TextView tv_softName;
		ImageView iv_softImage;
		TextView tv_geted_integral_num;
	}

}
